# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

#   http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Set up streetcar stops to use NextBus, set other stops to use TriMet WS

# lifted from http://code.google.com/p/transit-appliance-js-api/source/browse/trunk/assets/js/trArrAgencyTriMet.js?r=3#19
streetcarStops = {
    "8989": "n23mar_d",
    "3596": "loven22",
    "3595": "loven21",
    "10751": "loven18",
    "10752": "loven13",
    "10753": "n11john",
    "10754": "n11glis",
    "10755": "n11eve",
    "10756": "n11cou",
    "9600": "s11ald",
    "9633": "s11tay",
    "10759": "s11jeff",
    "10760": "s11clay",
    "11011": "marspark",
    "10762": "mars5",
    "10763": "mons5",
    "12375": "sw3harr",
    "12376": "sw1harr",
    "12377": "swharrd",
    "12378": "swrivmo",
    "12760": "swmogibb_a",
    "12880": "moodgain",
    "12881": "lowell_d",
    "12882": "bondlane",
    "12883": "bondohsu",
    "12760": "swmogibb_d",
    "12379": "swrivmo_h",
    "12380": "swharrd",
    "12381": "sw1harr",
    "12382": "sw3harr",
    "10764": "shop",
    "10766": "milspark",
    "10765": "s10clay",
    "6493" : "s10mad",
    "10767": "s10yam",
    "10768": "s10ald",
    "10769": "s10wash",
    "10770": "n10cou",
    "10771": "n10ev",
    "10772": "n10glis",
    "10773": "n10john",
    "10774": "n10mar",
    "12796": "nw12north",
    "10775": "northn14",
    "10776": "northn18",
    "10777": "northn21",
    "10778": "northn22"
    }

def stopMap(stop):
    # replace the avl_stop_id
    if streetcarStops.has_key(stop['stop_id']):
        stop['avl_stop_id'] = streetcarStops[stop['stop_id']]
        stop['avl_service'] = 'NextBus'
        stop['avl_agency_id'] = 'portland-sc'

    else:
        stop['avl_stop_id'] = stop['stop_id']
        stop['avl_service'] = 'TriMet'

    return stop
